@extends('Admin.index')

@section('css')
    <link rel="stylesheet" href="/css/login.css?v=20171128126">
    <link rel="stylesheet" href="/css/common.css?v=20171128126">
@endsection

@section('content')
    <div style="display: none;">登录页</div>
    <header class="login-header">
        {{--<div class="login-logo"><img src="/admin/images/left-logo.png"></div>--}}
    </header>
    <div class="login-banner">
        <div class="item-box">
            <div class="login-box">
                <div class="login-title">用户登录</div>
                <div class="form">
                    <div class="input-box">
                        <input type="text" value="" id="login_name" placeholder="请输入用户名"/>
                    </div>
                    <div class="input-box">
                        <input type="password" value="" id="password" placeholder="请输入密码"/>
                    </div>
                    <button class="btn-login">登录</button>
                </div>
            </div>
        </div>
    </div>
    <div class="fot">Copyright © 2006-2017 新墨有限公司 版权所有</div>
@endsection

@section('js')

    <script type="text/javascript">

        //登录
        function login() {

            var user_name = $.trim($('#login_name').val());
            var password = $.trim($('#password').val());

            if ( user_name == "" ) {
                layer.alert('请输入用户名',{icon:2});
                return false;
            }

            if ( password == "" ) {
                layer.alert('请输入密码',{icon:2});
                return false;
            }

            var layer_index = layer.load();
            $.ajax({
                type: 'GET',
                url:'login/do',
                data:{
                    login_name : user_name,
                    password : password
                },
                dataType: 'json',
                success: function(obj) {
                    layer.close(layer_index);
                    if (obj.code == 200) {
                        self.location = obj.data.redirect_url;
                    }else{
                        layer.alert(obj.message,{icon:2},function(){
                            $('#login_name').focus();
                            layer.closeAll();
                        });
                    }
                }
            });
        }

        $(function(){

            //点击登录
            $('button').click(function(){
                login();
            });

            //键盘回车登录
            $(document).keypress(function(e) {
                if(e.which == 13) {
                    login();
                }
            });
        });

    </script>
@endsection
